package com.zjut.szq.demo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zjut.szq.demo.dao.BaseDAO;
import com.zjut.szq.demo.model.Admin;
import com.zjut.szq.demo.service.AdminService;

@Service("adminService")
public class AdminServiceImpl implements AdminService {
	@Autowired
	private BaseDAO<Admin> baseDAO;

	/**
	 * 登录
	 */
	public Admin login(String userName, String password) {
		List<Admin> list = baseDAO.findByProperty(Admin.class, "userName", userName);
		if (list != null && list.size() > 0) {
			Admin admin = list.get(0);
			if (admin.getPassword().equals(password)) {
				return admin;
			} else {
				return null;
			}
		} else {
			return null;
		}
	}

	public BaseDAO<Admin> getBaseDAO() {
		return baseDAO;
	}

	public void setBaseDAO(BaseDAO<Admin> baseDAO) {
		this.baseDAO = baseDAO;
	}
}
